﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace CNFProblem.CNF
{
    /// <summary>
    /// Algorytm naiwny - sprawdza wszystkie mozliwosci
    /// </summary>
    class NaiveAlgorithm : IAlgorithm
    {
        public bool Compute(LogicalFormula3CNF formula, out Dictionary<int, bool> values)
        {
            values = formula.Variables.GetAsFalse();

            for (BigInteger i = 0; i < BigInteger.Pow(2, formula.Variables.Count); i++)
            {
                formula.Variables.Permute(i, values);
                if (formula.GetValue(values))
                {
                    return true;
                }
            }

            return false;
        }
    }
}
